package com.itheima.wemedia.controller;


import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import com.itheima.wemedia.dto.WmMaterialPageReqDto;
import com.itheima.wemedia.pojo.WmMaterial;
import com.itheima.wemedia.service.WmMaterialService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.itheima.core.controller.AbstractCoreController;

/**
 * @description <p>自媒体图文素材信息</p>
 *
 * @version 1.0
 * @package com.itheima.wemedia.controller
 */
@Api(value="WmMaterialController",tags = "自媒体图文素材信息")
@RestController
@RequestMapping("/material")
public class WmMaterialController extends AbstractCoreController<WmMaterial> {

    private WmMaterialService wmMaterialService;

    @Autowired
    public WmMaterialController(WmMaterialService wmMaterialService) {
        super(wmMaterialService);
        this.wmMaterialService=wmMaterialService;
    }

    @PostMapping("/list")
    public PageResultVo pagelist(@RequestBody WmMaterialPageReqDto dto){
      PageResultVo pageResultVo = wmMaterialService.pagelist(dto);
       return pageResultVo;
    }

    @GetMapping("/collect/{id}")
    public ResultVo collectById(@PathVariable(value = "id")Integer id){
        wmMaterialService.collenctById(id);
        return ResultVo.ok("收藏成功");
    }

    @GetMapping("/cancel_collect/{id}")
    public ResultVo cancelById(@PathVariable(value = "id")Integer id){
        wmMaterialService.cancelById(id);
        return ResultVo.ok("取消成功");
    }

    @GetMapping("/del_picture/{id}")
    public ResultVo delById(@PathVariable(value = "id")Integer id){
        wmMaterialService.delById(id);
        return ResultVo.ok("删除成功");
    }
}

